//
//  KSOrderInfoView.swift
//  Supermarket
//
//  Created by liuxm on 2017/9/27.
//  Copyright © 2017年 kushao. All rights reserved.
//

import UIKit

class KSOrderInfoView: UIView {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    
    
    /// 衣服
    lazy var clothesImageView: UIImageView = {
        let imageView = UIImageView(image: UIImage(named: "Home_Clothes"))
        imageView.frame = CGRect(x: 10, y: 0, width: 90, height: 90)
        
        self.addSubview(imageView)
        return imageView
    }()
    
    /// 说明
    lazy var clothesInfoLabel: UILabel = {
       let clothesInfoLabel = UILabel()
        clothesInfoLabel.font = UIFont.systemFont(ofSize: 15)
        clothesInfoLabel.textColor = KSColor.kColor_3
        clothesInfoLabel.numberOfLines = 0
        clothesInfoLabel.lineBreakMode = .byWordWrapping
        return clothesInfoLabel
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.white
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func initView() {
        clothesImageView.frame = CGRect(x: 10, y: 10, width: 90, height: 90)
        self.addSubview(clothesImageView)
        
        /// 说明
        clothesInfoLabel.frame = CGRect(x: clothesImageView.frame.size.width + clothesImageView.frame.origin.x
             + 10, y: clothesImageView.frame.origin.y, width: KSConstants.kScreenWidth - (clothesImageView.frame.size.width + clothesImageView.frame.origin.x) - 20, height: 40)
        clothesInfoLabel.text = "G 男装207 春款新款 男士薄款黑色连帽运动夹克外套"
        self.addSubview(clothesInfoLabel)
        
        let tempArray = ["", ""]
        let count = tempArray.count
        let detailViewH:CGFloat = 90.0
        let viewW = KSConstants.kScreenWidth - 20.0
        for i in 0 ..< count {
            let detailView = UIView(frame: CGRect(x: 10.0, y: clothesImageView.frame.size.height + clothesImageView.frame.origin.y + 10.0 + CGFloat(i) * 100.0, width: viewW, height: detailViewH))
            detailView.backgroundColor = KSColor.kColorLightGray
            self.addSubview(detailView)
            
            /// 规格
            let specTitleLabel = UILabel(frame: CGRect(x: 10, y: 10, width: 80, height: 20))
            specTitleLabel.font = UIFont.systemFont(ofSize: 15)
            specTitleLabel.textColor = KSColor.kColor_3
            specTitleLabel.text = "组合规格："
            detailView.addSubview(specTitleLabel)
            
            let specLabel = UILabel(frame: CGRect(x: specTitleLabel.frame.origin.x + specTitleLabel.frame.size.width + 10, y: specTitleLabel.frame.origin.y, width: viewW - 100, height: 20))
            specLabel.font = UIFont.systemFont(ofSize: 15)
            specLabel.textColor = KSColor.kColor_3
            specLabel.text = "XL；绿色"
            detailView.addSubview(specLabel)
            
            /// 位置
            let positionTitleLabel = UILabel(frame: CGRect(x: 10, y: specTitleLabel.frame.origin.y + specTitleLabel.frame.size.height + 5, width: 80, height: 20))
            positionTitleLabel.font = UIFont.systemFont(ofSize: 15)
            positionTitleLabel.textColor = KSColor.kColor_3
            positionTitleLabel.text = "货架位置："
            detailView.addSubview(positionTitleLabel)
            
            let positionLabel = UILabel(frame: CGRect(x: positionTitleLabel.frame.origin.x + positionTitleLabel.frame.size.width + 10, y: positionTitleLabel.frame.origin.y, width: viewW - 100, height: 20))
            positionLabel.font = UIFont.systemFont(ofSize: 15)
            positionLabel.textColor = KSColor.kColor_3
            positionLabel.text = "1排4列5层"
            detailView.addSubview(positionLabel)
            
            /// 数量
            let quantityTitleLabel = UILabel(frame: CGRect(x: 10, y: positionTitleLabel.frame.origin.y + positionTitleLabel.frame.size.height + 5, width: 80, height: 20))
            quantityTitleLabel.font = UIFont.systemFont(ofSize: 15)
            quantityTitleLabel.textColor = KSColor.kColor_3
            quantityTitleLabel.text = "数量："
            detailView.addSubview(quantityTitleLabel)
            
            let quantityLabel = UILabel(frame: CGRect(x: quantityTitleLabel.frame.origin.x + quantityTitleLabel.frame.size.width + 10, y: quantityTitleLabel.frame.origin.y, width: viewW - 100, height: 20))
            quantityLabel.font = UIFont.systemFont(ofSize: 15)
            quantityLabel.textColor = KSColor.kColor_3
            quantityLabel.text = "20件"
            detailView.addSubview(quantityLabel)
        }
    }
}
